home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Dialectic 1.2 / source / Dialectic ƒ / Raw dialects ƒ / chef.c next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  4.8 KB  |  241 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        chef.c
  4.  
  5. Purpose:    This module handles actually converting text into Chef talk.
  6.  
  7.  
  8. Dialectic -=- dialect text conversion extraordinare
  9. Copyright ©1994, Mark Pilgrim
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "dialectic dispatch.h"
  29. #include "dialectic utilities.h"
  30. #include "program globals.h"
  31.  
  32. void ConvertChef(void)
  33. {
  34.     char            oneChar;
  35.     
  36.     oneChar=(ThisChar())|0x20;
  37.     
  38.     if ((ThisChar()=='.') && (NextChar(1)==0x0d))
  39.     {
  40.         gInWord=gSeenI=FALSE;
  41.         StoreChar('.');
  42.         StoreChar(0x0d);
  43.         StoreString("\pBork Bork Bork!");
  44.         InputPlus(1);
  45.         return;
  46.     }
  47.     
  48.     if (!IsAlpha(ThisChar()))
  49.     {
  50.         gInWord=gSeenI=FALSE;
  51.         StoreChar(ThisChar());
  52.         InputPlus(1);
  53.         return;
  54.     }
  55.     
  56.     if ((!gInWord) && (oneChar=='b') && ((NextChar(1)|0x20)=='o')
  57.             && ((NextChar(2)|0x20)=='r') && ((NextChar(3)|0x20)=='k'))
  58.     {
  59.         gInWord=TRUE;
  60.         StoreChar(ThisChar());
  61.         StoreChar(NextChar(1));
  62.         StoreChar(NextChar(2));
  63.         StoreChar(NextChar(3));
  64.         InputPlus(4);
  65.         return;
  66.     }
  67.     
  68.     if ((oneChar=='a') && ((NextChar(1)|0x20)=='n'))
  69.     {
  70.         gInWord=TRUE;
  71.         StoreChar(ThisChar()+'u'-'a');
  72.         StoreChar(NextChar(1));
  73.         InputPlus(2);
  74.         return;
  75.     }
  76.     
  77.     if ((oneChar=='a') && ((NextChar(1)|0x20)=='u'))
  78.     {
  79.         gInWord=TRUE;
  80.         StoreChar(ThisChar()+'o'-'a');
  81.         StoreChar(NextChar(1)+'o'-'u');
  82.         InputPlus(2);
  83.         return;
  84.     }
  85.     
  86.     if ((oneChar=='a') && (IsAlpha(NextChar(1))))
  87.     {
  88.         gInWord=TRUE;
  89.         StoreChar(ThisChar()+'e'-'a');
  90.         InputPlus(1);
  91.         return;
  92.     }
  93.     
  94.     if ((oneChar=='e') && ((NextChar(1)|0x20)=='n') && (!IsAlpha(NextChar(2))))
  95.     {
  96.         gInWord=TRUE;
  97.         StoreChar(ThisChar());
  98.         StoreChar(NextChar(1)+'e'-'n');
  99.         InputPlus(2);
  100.         return;
  101.     }
  102.     
  103.     if ((gInWord) && (oneChar=='e') && ((NextChar(1)|0x20)=='w'))
  104.     {
  105.         StoreChar(ThisChar()+'o'-'e');
  106.         StoreChar(NextChar(1)+'o'-'w');
  107.         InputPlus(2);
  108.         return;
  109.     }
  110.     
  111.     if ((gInWord) && (oneChar=='e') && (!IsAlpha(NextChar(1))))
  112.     {
  113.         StoreChar(ThisChar());
  114.         StoreChar('-');
  115.         StoreChar(ThisChar()+'a'-'e');
  116.         InputPlus(1);
  117.         return;
  118.     }
  119.     
  120.     if ((!gInWord) && (oneChar=='e'))
  121.     {
  122.         gInWord=TRUE;
  123.         StoreChar(ThisChar()+'i'-'e');
  124.         InputPlus(1);
  125.         return;
  126.     }
  127.     
  128.     if ((gInWord) && (oneChar=='f'))
  129.     {
  130.         StoreChar(ThisChar());
  131.         StoreChar(ThisChar());
  132.         InputPlus(1);
  133.         return;
  134.     }
  135.     
  136.     if ((gInWord) && (oneChar=='i') && ((NextChar(1)|0x20)=='r'))
  137.     {
  138.         StoreChar(ThisChar()+'u'-'i');
  139.         StoreChar(NextChar(1));
  140.         InputPlus(2);
  141.         return;
  142.     }
  143.     
  144.     if ((gInWord) && (oneChar=='i'))
  145.     {
  146.         if (gSeenI)
  147.             StoreChar(ThisChar());
  148.         else
  149.         {
  150.             StoreChar(ThisChar()+'e'-'i');
  151.             StoreChar(ThisChar()+'e'-'i');
  152.         }
  153.         gSeenI=TRUE;
  154.         InputPlus(1);
  155.         return;
  156.     }
  157.     
  158.     if ((gInWord) && (oneChar=='o') && ((NextChar(1)|0x20)=='w'))
  159.     {
  160.         StoreChar(ThisChar());
  161.         StoreChar(NextChar(1)+'o'-'w');
  162.         InputPlus(2);
  163.         return;
  164.     }
  165.     
  166.     if ((!gInWord) && (oneChar=='o'))
  167.     {
  168.         gInWord=TRUE;
  169.         StoreChar(ThisChar());
  170.         StoreChar(((ThisChar()=='O') && (IsUpperAlpha(NextChar(1)))) ? 'O' : 'o');
  171.         InputPlus(1);
  172.         return;
  173.     }
  174.     
  175.     if ((gInWord) && (oneChar=='o'))
  176.     {
  177.         StoreChar(ThisChar()+'u'-'o');
  178.         InputPlus(1);
  179.         return;
  180.     }
  181.     
  182.     if ((oneChar=='t') && ((NextChar(1)|0x20)=='h') && ((NextChar(2)|0x20)=='e'))
  183.     {
  184.         gInWord=TRUE;
  185.         StoreChar(ThisChar()+'z'-'t');
  186.         StoreChar(NextChar(1)+'e'-'h');
  187.         StoreChar(NextChar(2));
  188.         InputPlus(3);
  189.         return;
  190.     }
  191.     
  192.     if ((oneChar=='t') && ((NextChar(1)|0x20)=='h') && (!IsAlpha(NextChar(2))))
  193.     {
  194.         gInWord=TRUE;
  195.         StoreChar(ThisChar());
  196.         InputPlus(2);
  197.         return;
  198.     }
  199.     
  200.     if ((gInWord) && (oneChar=='t') && ((NextChar(1)|0x20)=='i') &&
  201.         ((NextChar(2)|0x20)=='o') && ((NextChar(3)|0x20)=='n'))
  202.     {
  203.         gInWord=TRUE;
  204.         StoreChar(ThisChar()+'s'-'t');
  205.         StoreChar(NextChar(1)+'h'-'i');
  206.         StoreChar(NextChar(2)+'u'-'o');
  207.         StoreChar(NextChar(3));
  208.         InputPlus(4);
  209.         return;
  210.     }
  211.     
  212.     if ((gInWord) && (oneChar=='u'))
  213.     {
  214.         gInWord=TRUE;
  215.         StoreChar(ThisChar()+'o'-'u');
  216.         StoreChar((IsUpperAlpha(NextChar(1))) ? 'O' : 'o');
  217.         InputPlus(1);
  218.         return;
  219.     }
  220.     
  221.     if (oneChar=='v')
  222.     {
  223.         gInWord=TRUE;
  224.         StoreChar(ThisChar()+'f'-'v');
  225.         InputPlus(1);
  226.         return;
  227.     }
  228.     
  229.     if (oneChar=='w')
  230.     {
  231.         gInWord=TRUE;
  232.         StoreChar(ThisChar()+'v'-'w');
  233.         InputPlus(1);
  234.         return;
  235.     }
  236.     
  237.     gInWord=TRUE;
  238.     StoreChar(ThisChar());
  239.     InputPlus(1);
  240. }
  241.